<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\LogSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

\backend\assets\DataTableAsset::register($this);

$this->title = Yii::t('app', 'Logs');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="log-index">

    <div class="box">
        <div class="box-header">
            <h3 class="box-title"><?= Yii::t('app', 'Logs')?></h3>
            <div class="box-tools">
                <ul class="pagination pagination-sm no-margin pull-right">
                    <li><a id="dt_refresh_a" href="#" onclick="dt_refresh_btn_on_click();"><i class="fa fa-refresh"></i></a></li>
                </ul>
            </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
            <table id="log_table" class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>id</th>
                    <th>action</th>
                    <th>old_content</th>
                    <th>new_content</th>
                    <th>memo</th>
                    <th>created_by</th>
                    <th>created_at</th>
                    <th>updated_by</th>
                    <th>updated_at</th>
                    <th>all_content</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
                <tfoot>
                <tr>
                </tr>
                </tfoot>
            </table>
        </div>
        <!-- /.box-body -->
    </div>

</div>
<script>
    <?php $this->beginBlock('js_running')?>

    var dt;

    function loadDataTable() {
        dt = $('#log_table').DataTable({
            "paging":   true,
            'aLengthMenu': [[10, 20, 50], ['10', '20', '50']],  //设置每页显示记录的下拉菜单
            "ordering": true,
            "info":     true,
            "scrollX": true,
            "processing": true,
            "serverSide": true,
            'stateSave' : true,
            // "searching": false,
            "ajax": {
                "url" : "/log/ajax-get-list",
                'type': 'get'
            },
            'language': {
                "processing": "正在处理中。。。",
                "info": "正在显示第 _START_ 条至第 _END_ 条数据， 总共 _TOTAL_ 条数据",
                // "infoEmpty": "正在显示第 0 条至第 0 条数据， 总共 0 条数据",
                "paginate": {
                    "first": "第一页",
                    "last": "最后一页",
                    "next": "下一页",
                    "previous": "上一页",
                    "search": "过滤记录:"
                },
                'lengthMenu' : '显示 _MENU_ 项结果'
            },
            "order": [[0, 'desc']],
            "columnDefs": [
                { "visible": false,  "targets": [ 0 ] }
                // ,
                // {
                //     // 第1列为name
                //     "render": function ( data, type, row ) {
                //         // return data +' ('+ row[3]+')';
                //         return "<a href=\"/kingdee/person/view?id="+encodeURIComponent(row['fid'])+"\" target=\"_blank\">"+data+"</a>";
                //     },
                //     "targets": 1
                // }
            ],
            "columns": [
                { "data": "id", 'title' : 'id号' },
                { "data": "action", 'title' : '行为' },
                { "data": "old_content", 'title' : '旧内容' },
                { "data": "new_content", 'title' : '新内容' },
                { "data": "memo", 'title' : '备注' },
                { "data": "created_by", 'title' : '创建者' },
                { "data": "created_at", 'title' : '创建时间' },
                { "data": "updated_by", 'title' : '最后修改者' },
                { "data": "updated_at", 'title' : '最后修改时间' },
                { "data": "all_content", 'title' : '所有' }
            ]
        });
        return dt;
    }

    $(document).ready(function() {
        dt = loadDataTable();
    });
    
    function dt_refresh_btn_on_click() {
        dt.ajax.reload();
    }
    <?php $this->endBlock()?>
</script>
<?php
$this->registerJs($this->blocks['js_running'], \yii\web\View::POS_END)
?>
